
$(function() {

	$("a[id^='material_']").click(function() {
		$('#dialog_view').dialog('option', 'buttons', {

			"关闭": function() {
				$(this).dialog("close");
			}
		});

		var url = $(this).attr('href') + "&bt=1";
		var title = "材料信息";
		var xy = "550x360";

		dialog_view(url, title, xy);
		return false;
	});

	var options = {
		zoomWidth: 300,
		zoomHeight: 240,
		xOffset: 20,
        title: false,
		zoomType:'reverse'
	}
    
	$("a[id^='zoom_']").jqzoom(options);	
});

function a1(e, p2, id, status) {
	$.cookie('id_', id);

	$.cookie('status_', status);

	p2 = query(p2);
	$.cookie('p2', p2);

	var c1 = 'material.php?do=Pic.edit&id=' + id;
	var c2 = 'material.php?do=Pic.view&id=' + id;

	var a1 = ['编辑信息', 'url', 'dialog_edit_', '600x400', '编辑信息'];
	var a2 = ['材料信息', 'url', 'dialog_view_', '600x400', '材料信息'];	

	var s = c2;

	return popup(e, [a2], s);
}

function dialog_edit_(url, title, xy) {
	$.getJSON('material.php?do=Material.audit&item=51', function(json) {
		if (json.status == 1) {
			$('#dialog_edit').dialog('option', 'buttons', {

				"关闭": function() {
					$(this).dialog("close");
				},

				"修改": function() {
					if (!confirm("确认是否提交？")) {
						return false;
					}

					var form = $("#form_edit")[0];

					var body = {};
					body.id = form.id.value;
					body.orderby = form.orderby.value;

					$(this).dialog("close");

					var url = 'material.php?do=Pic.editPost';
					var p2 = $.cookie('p2');
					if (p2 != null) {
						url += p2;
					}

					$.post(url, body, function(data) {
						$(result).html(data);
					});
				}
			});

			dialog_edit(url, title, xy);
		} else {
			_error();
		}
	});
}

function dialog_view_(url, title, xy) {
	$('#dialog_view').dialog('option', 'buttons', {

		"关闭": function() {
			$(this).dialog("close");
		}
	});

	dialog_view(url, title, xy);
}

function list_pic(url, view) {
	$.getJSON('material.php?do=Pic.audit&item=52', function(json) {
		if (json.status == 1) {
			if (confirm("是否设为缺省图片？")) {
				list(url, view);
			}
		} else {
			_error();
		}
	});
}

function expunge_(form) {
	$.getJSON('material.php?do=Material.audit&item=52', function(json) {
		if (json.status == 1) {
			expunge(form);
		} else {
			_error();
		}
	});
}